package com.qztc.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

import static com.qztc.config.GlobalConfig.SERVICE_URL;


@RestController
@RequestMapping("/consumer/verify")
@Tag(name = "验证码生成接口")
public class VerifyCodeControllerByRestTemplate {

    @Autowired
    private RestTemplate restTemplate;

    @Operation(summary = "生成验证码")
    @GetMapping("/generateVerifyCode")
    public String generateVerifyCode() {
        return restTemplate.getForObject(SERVICE_URL+"/verify/generateVerifyCode", String.class);
    }

    @Operation(summary = "验证验证码")
    @PostMapping("/checkVerifyCode")
    public String checkVerifyCode(@RequestBody Map<String, String> verifyParams) {
        return restTemplate.postForObject(SERVICE_URL +"/verify/checkVerifyCode", verifyParams, String.class);
    }
}
